using System;
using System.Xml;

namespace umlungu.engineX.webX.thoughts.Admin.service {
	/// <summary>
	/// umlungu engineX web framework, xxx class.
	/// </summary>
	public class servicexxxX : SoapX
	{
		/// <summary>
		/// Local objects and properties
		/// </summary>
		private string propxxxX;
		public string PropxxxX	{
			get	{	return propxxxX;	}	
			set	{	propxxxX = value;	}
		}
		
		/// <summary>
		/// Public properties
		/// </summary>
		
		#region Public methods
		/// <summary>Constructor</summary>
		public servicexxxX() : base("service", "service_x") {
		}
		#endregion

		#region Protected methods
		/// <summary>
		/// Method _Process:: overrides the base method to call a private method of this class
		/// </summary>
		protected override void _Process(XmlDocument xmldom, profileX profile, contentX content) {
			//_Debug("servicexxxX._ProcessXml", "xmldom:", xmldom.OuterXml);
			_Debug("servicexxxX._ProcessXml", "profile:", profile.Xml.InnerXml);
			_Debug("servicexxxX._ProcessXml", "content:", content.Xml.InnerXml);
			
			switch (Process) {
				default:
				case "Login":
					ProcessResult(new ProcessServiceResult(processLogin));
					break;
			}

			_Debug("servicexxxX._ProcessXml", "profile:", profile.Xmldoc.OuterXml);
		}
		#endregion

		#region Private methods
		/// <summary>
		/// Sample method:: borrows from original "getLoginXml"
		/// </summary>
		private void processLogin(XmlDocument xmldom, profileX profile, contentX content) {
			XmlElement usrnode = (XmlElement) xmldom.SelectSingleNode("//user");
			if (usrnode != null) {
				_Debug("method", "usrnode", usrnode.InnerXml);
				profile.AddProfileValue("Token", usrnode.GetAttribute("token"));
				profile.AddProfileValue("Firstname", usrnode.SelectSingleNode("firstname").InnerText);
				profile.AddProfileValue("Surname", usrnode.SelectSingleNode("surname").InnerText);
				profile.AddProfileValue("Email", usrnode.SelectSingleNode("email").InnerText);
			}
		}
		#endregion
	}
}
		
